import AddInvester from '../../common/add-invester/add-invester.vue'
import UpdateInvester from '../../common/update-invester/update-invester.vue'
import { getInvesterList, showMsg } from '../../../../../vuex/action.js'
import extend from 'extend'

export default {
  name: 'InvesterList',
  data() {
    return {
      serverRoot: server.root,
      investerList: [],
      pages: {
        start: 0,
        limit: 99999
      }
    }
  },
  methods: {
    deepClone(obj) {
      return extend(true, {}, obj)
    },
    getInvesterList() {
      this.xGetInvesterList(this.pages)
        .then((res) => {
          this.investerList = res.data.list
        }).catch((res) => {
          this.xShowMsg({
            type: 'danger',
            content: res.error_msg
          })
        })
    }
  },
  events: {
    on_refresh_list() {
      this.getInvesterList()
    }
  },
  vuex: {
    actions: {
      xGetInvesterList: getInvesterList,
      xShowMsg: showMsg
    }
  },
  components: {
    'add-invester': AddInvester,
    'update-invester': UpdateInvester
  },
  ready() {
    this.getInvesterList()
  }
}
